package com.base.llpark.utills;

import android.content.Context;
import android.widget.ImageView;

import com.base.llpark.R;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

import java.io.File;

/**
 * Created by arvin on 2018/11/7.
 */

public class GlideUtil {
    public static  void load(Context context,String url, ImageView v)
    {
        RequestOptions options = new RequestOptions()
                .error(com.base.commonlib.R.drawable.ic_holder_b)
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(com.base.commonlib.R.drawable.ic_holder_b);
        Glide.with(context).load(url).apply(options).into(v);
    }

    public static void loadFile(Context context,String path, ImageView v)
    {
        RequestOptions options = new RequestOptions()
                .error(com.base.commonlib.R.drawable.ic_holder_b)
                .placeholder(com.base.commonlib.R.drawable.ic_holder_b);
        Glide.with(context).load(new File(path)).apply(options).into(v);
    }
    public static void loadResource(Context context,Integer id, ImageView v)
    {
        RequestOptions options = new RequestOptions()
                .error(com.base.commonlib.R.drawable.ic_holder_b)
                .placeholder(com.base.commonlib.R.drawable.ic_holder_b);
        Glide.with(context).load(id).apply(options).into(v);
    }

    public static void load_nocatch(Context context,String url, ImageView v)
    {
        RequestOptions options = new RequestOptions()
                .error(com.base.commonlib.R.drawable.ic_holder_b)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .placeholder(com.base.commonlib.R.drawable.ic_holder_b);
        Glide.with(context).load(url).apply(options).into(v);

    }
}
